package com.js.sys.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import java.util.List;

/**
 * viewpager fragment adapter
 */
public class PagerFragmentAdapter extends FragmentStateAdapter {
    private String[] mTitles;//tab名称
    private List<Fragment> mFragments;//fragment
    public PagerFragmentAdapter(@NonNull FragmentActivity fragmentActivity, List<Fragment> fragments) {
        super(fragmentActivity);
//        mTitles = titles;
        mFragments=fragments;
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        return mFragments.get(position);
    }

    @Override
    public int getItemCount() {
        return mFragments.size();
    }
}